<template>
	<div class="pages">
		<el-form :inline="true" size="small" :model="dataForm" label-width="80px">
			<el-form-item label="订单编号:">
				<el-input v-model="dataForm.keyword" placeholder="请输入" clearable></el-input>
			</el-form-item>
			<el-form-item label="需求类型:">
				<el-select v-model="dataForm.level" placeholder="请选择" clearable>
					<el-option v-for="item in xqList" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="签署状态:">
				<el-select v-model="dataForm.status" placeholder="请选择" clearable>
					<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="getDataList">搜索</el-button>
			</el-form-item>
		</el-form>
		<el-table :data="dataList" v-loading="dataListLoading" border style="width: 100%" header-align="center">
			<el-table-column type="index" align="center" label="序号" width="60">
			</el-table-column>
			<el-table-column prop="order_sn" align="center" label="订单号">
			</el-table-column>
			<el-table-column prop="corp" align="center" label="企业名称">
			</el-table-column>
			<el-table-column prop="level" align="center" label="需求类型">
				<template slot-scope="scope">
					<span v-if="scope.row.level==1">设计研发需求</span>
					<span v-if="scope.row.level==2">物资采购需求</span>
					<span v-if="scope.row.level==3">加工制造需求</span>
				</template>
			</el-table-column>
			<el-table-column prop="title" align="center" label="需求名称">
			</el-table-column>
			<el-table-column prop="factory_name" align="center" label="共享工厂">
			</el-table-column>
			<el-table-column prop="hetong_num" align="center" label="合同金额(元)">
			</el-table-column>
			<el-table-column prop="fuwu_num" align="center" label="服务费用(元)">
			</el-table-column>
			<el-table-column prop="coupons_num" align="center" label="创制券申请额度(元)">
			</el-table-column>
			<el-table-column align="center" label="合同状态">
				<template slot-scope="scope">
					<el-tag type="warning" v-if="scope.row.hetong_status=='未签署'">未签署</el-tag>
					<el-tag type="success" v-if="scope.row.hetong_status=='已签署'">已签署</el-tag>
					<el-tag type="danger" v-if="scope.row.hetong_status=='已作废'">已作废</el-tag>
				</template>
			</el-table-column>
			<el-table-column prop="create_time" align="center" label="合同预览">
				<template slot-scope="scope">
					<el-button type="primary" size="small">
						<el-link :href="url+scope.row.thumb" target="_blank" style="color: #fff;"
							:underline="false">预览</el-link>
					</el-button>
				</template>
			</el-table-column>
			<el-table-column prop="create_time" align="center" label="归档时间">
			</el-table-column>
			<el-table-column align="center" label="操作" width="100">
				<template slot-scope="scope">
					<el-button type="text" @click="showDetail(scope.row)">查看详情</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
		<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
	</div>
</template>

<script>
	import mixinViewModule from '@/mixins/view-module'
	import AddOrUpdate from './add-or-update'
	export default {
		mixins: [mixinViewModule],
		data() {
			return {
				mixinViewModuleOptions: {
					getDataListURL: '/api/coupons/getList',
					getDataListIsPage: true,
					deleteURL: '',
					deleteIsBatch: true,
					createdIsNeed: true,
				},
				dataForm: {
					keyword: '',
					level: '',
					status: ''
				},
				xqList: [{
					value: 1,
					label: '设计研发需求'
				}, {
					value: 2,
					label: '物资采购需求'
				}, {
					value: 3,
					label: '加工制造需求'
				}],
				statusList: [{
					value: 0,
					label: '未签署'
				}, {
					value: 1,
					label: '已签署'
				}, {
					value: 2,
					label: '已作废'
				}],
				url: ''
			}
		},
		components: {
			AddOrUpdate
		},
		methods: {
			onSubmit() {
				console.log('submit!');
			},
			showDetail(row) {
				this.$router.push({
					path: '/order/detail',
					query: {
						id: row.order_id
					}
				})
			},
		},
		created() {
			this.url = process.env.VUE_APP_BASE_API
		}
	}
</script>